home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
pcb51a.zip
/
PCBMAIL.WAS
< prev
next >
Wrap
Text File
|
1992-09-20
|
11KB
|
392 lines
; PCBMAIL.WAS v.5.1a - 9/20/92 06:40 AM
; Copyright (c) 1992, Gregg Hommel, All Rights Reserved
; PCBMAIL.WAS is a Windows Aspect script for use with ProComm Plus for
; Windows, version 1.01. It uses information set through the script,
; SETMAIL.WAS, to perform semi-automated or automated mail runs on PCBoard
; systems with Qmail doors.
integer status=0, sendrep=0, b1=1, b2=1, b3=1, getmail=0, flag=0
integer secnum = 10, flagbye=0, watchfor, taska, taskb, lang=0, graph=0
string ini = "PCBMAIL.INI", board, door, maildir, defconf, ren_def
string conf, mailcmd, reply, isrep, mailstr, doorcmd, secleft, prompt_str
proc main
string uppath
set connection statmsg on
when target 0 "?" call get_prompt
when target 1 "continue..." call send_ret
when userexit call done_now
when cdchanges call done_now
set dialdir access $DIALENTRY
read_ini()
; If you have not used SETMAIL to set the parameters which PCBMail needs
; for a system, all it will do is a simple log on, based on the UserID and
; Password as set in the dialing directory. PCBMail will warn you that this
; is the case, log on to the board, then remain running in the background
; until you log off the board.
if null_str(board)
errormsg "%s is not set up. Logging on only!" $D_NAME
taskb = 1
if taska
watchfor = 0
endif
return
endif
; PCBMail looks in the default upload directory for a REP file for this
; board. If it finds one, it will automatically upload it to Qmail, and
; then delete it after the upload.
fetch upldpath uppath
strfmt reply "%s\%s.REP" uppath board
if isfile reply
statmsg "%s.REP exists." board
sendrep=1
strfmt isrep "Send %s.REP only" board
else
statmsg "No %s.REP to send." board
strfmt isrep "Skip %s mailrun." board
endif
strfmt mailstr "Get new %s mail" board
; Depending on whether you have set up this board to allow joining an
; alternate conference (if you remain online), PCBMail will present a
; dialog box where you can set options for this mail run. New to 5.1a is a
; timer function, which will automatically accept the default dialog
; settings if you do not make an alternative selection within ten seconds.
; This will allow you to perform an unattended mail run, if you wish.
strfmt secleft "%d" secnum
if null_str(defconf)
alt_dlg_make()
else
std_dlg_make()
endif
when elapsed 1 call time_up
when dialog call check_it
holding()
statmsg "Log in completed - %s" $D_NAME
if sendrep || getmail
strfmt doorcmd "open %s^M" door
transmit doorcmd
when target 2 "^xB01" call rep_goes
when filexfer call check_xfer
holding()
elseif flagbye
transmit mailcmd
endif
if not flagbye
if not null_str(conf)
transmit conf
holding()
endif
clearwhen target 0
statmsg "Remaining online with %s." $D_NAME
endif
holding()
endproc
; Proc get_prompt is where PCBMail searches the prompts sent by PCBoard or
; Qmail to locate various key words or phrases. If one of these is found,
; the appropriate response is sent.
proc get_prompt
termgets $ROW 0 prompt_str $COL
if chk_prompt("Command")
if chk_prompt("Qmail")
send_cmd()
else
taska=1
if taskb
watchfor=0
endif
endif
elseif chk_prompt("Enter)=yes?") || chk_prompt("More?") || chk_prompt ("Enter = Yes?")
transmit "N^M"
elseif chk_prompt("=no change?") && lang==0
transmit "^M"
lang++
elseif chk_prompt("Enter)=no?") || chk_prompt("continue?") || chk_prompt("=none?") || chk_prompt("Enter = No?")
if chk_prompt("graphics") || chk_prompt("Color?") && graph==0
transmit "N Q NS^M"
graph++
else
transmit "^M"
endif
elseif chk_prompt("Password (Dots")
transmit $PASSWORD
transmit "^M"
elseif chk_prompt("name?")
transmit $USERID
transmit " "
transmit $PASSWORD
transmit "^M"
elseif chk_prompt("new user?") || chk_prompt("new caller?")
transmit "r^M"
endif
endproc
; Windows Aspect has a limitation on using certain internal functions in
; if..else conditionals. Several commands such as strfind and nullstr, can
; only be used once per conditional test. To circumvent this restriction,
; the next two functions are used.
func chk_prompt:integer
strparm chk_out
strfind prompt_str chk_out
return FOUND
endfunc
func null_str:integer
strparm test_var
integer result
nullstr test_var result
return result
endfunc
; Due to the asynchronous nature of some of the commands in Windows Aspect,
; it may be necessary to, at times, wait for a command to complete before
; starting on another set. This useful little procedure performs that task.
proc holding
watchfor=1
while watchfor
endwhile
endproc
proc std_dlg_make
dialogbox 129 42 127 150 11 "System Options"
groupbox 10 6 101 45 "Qmail" shadow
radiobutton 14 20 10 10 "" b1
radiobutton 14 35 10 10 "" endgroup
vtext 24 21 85 10 left mailstr
vtext 24 36 85 10 left isrep
groupbox 10 58 47 45 "Board" shadow
radiobutton 15 69 35 10 "Log Off" b2
radiobutton 15 85 40 10 "Stay On" endgroup
groupbox 64 58 47 45 "Join" shadow
radiobutton 68 70 29 10 "Main" b3
radiobutton 68 85 42 10 "Alternate" endgroup
text 10 110 70 8 right "Using defaults in "
vtext 80 110 8 8 center secleft
text 92 110 16 8 left "secs."
pushbutton 10 123 102 15 "GO" normal default
enddialog
disable ctrl 52
endproc
proc alt_dlg_make
dialogbox 129 42 127 150 11 "System Options"
groupbox 10 6 101 45 "Qmail" shadow
radiobutton 14 20 10 10 "" b1
radiobutton 14 35 10 10 "" endgroup
vtext 24 21 85 10 left mailstr
vtext 24 36 85 10 left isrep
groupbox 38 59 47 45 "Board" shadow
radiobutton 43 70 35 10 "Log Off" b2
radiobutton 43 85 40 10 "Stay On" endgroup
text 10 110 70 8 right "Using defaults in "
vtext 80 110 8 8 center secleft
text 92 110 16 8 left "secs."
pushbutton 10 123 102 15 "GO" normal default
enddialog
endproc
proc check_it
integer dlgstatus
clearwhen elapsed
secleft = $NULLSTR
updatedlg 64
dlgstatus = $DIALOG
while dlgstatus != 10
if dlgstatus == 51 && b2 == 1
disable ctrl 52
elseif dlgstatus == 51 && b2 == 2
enable ctrl 52
endif
return
endwhile
set_parms()
endproc
proc set_parms
clearwhen dialog
if b1 == 1
getmail = 1
mailcmd = "D;Y;"
endif
if b2 == 1
strcat mailcmd "G^M"
flagbye = 1
else
strcat mailcmd "Q^M"
if b3 == 2
strfmt conf "J %s^M" defconf
endif
endif
taskb = 1
if taska
watchfor = 0
endif
endproc
; This is the procedure which manages the countdown timer used in the
; dialog box, to control unattended running of the script.
proc time_up
secnum--
strfmt secleft "%d" secnum
updatedlg 64
if secnum == 0
clearwhen elapsed
destroydlg
set_parms()
endif
endproc
; Proc send_cmd is used to send the appropriate commands to Qmail in order
; to perform the mail run specified by the dialog box options set.
proc send_cmd
if isfile reply
transmit "U^M"
elseif not getmail
transmit mailcmd
watchfor -= flagbye
elseif not flag
transmit mailcmd
statmsg "%s is scanning for mail." $D_NAME
flag = 1
watchfor -= flagbye
clearwhen target 2
when target 2 "PCBoard now" call mail_done
endif
endproc
proc rep_goes
sendfile ZMODEM reply
endproc
; This procedure does nothing more than monitor the transfer of the mail
; files. If the transferred file is a REP, it will be deleted after a
; successful upload.
proc check_xfer
status = $FILEXFER
while status == 1
status = $FILEXFER
endwhile
if status == 2
if isfile reply
delfile reply
statmsg "%s.REP sent and deleted." board
endif
endif
status = 0
endproc
proc mail_done
clearwhen filexfer
clearwhen target 2
endproc
proc send_ret
transmit "^M"
endproc
proc read_ini
profilerd ini $D_NAME "board_ID" board
profilerd ini $D_NAME "door_ID" door
profilerd ini $D_NAME "mail_dir" maildir
profilerd ini $D_NAME "def_conf" defconf
profilerd ini $D_NAME "rename_as" ren_def
endproc
; Proc ren_qwks is the mail management section of PCBMail. It is here that
; new mail packets are renamed and moved (if necessary), allowing you to
; keep several packets without concern about overwriting files, etc.
proc ren_qwks
integer count, test=0, char, char2, max=0, ltr, len
string newqwk, oldqwk, renqwk, newfile, root, sdate, dldir
if null_str(ren_def)
root = board
else
substr sdate $DATE 0 5
strdelete sdate 2 1
strfmt root "%s%s" board sdate
strlen root len
if len > 8
len -= 8
strdelete root 4 len
endif
endif
strfmt oldqwk "%s\%s.QW?" maildir root
if findfirst oldqwk
max++
while 1
if findnext
max++
else
exitwhile
endif
endwhile
endif
max--
for count = 0 upto max
char = 65 + count
strfmt oldqwk "%s\%s.qw%c" maildir root char
if findfirst oldqwk
loopfor
else
for test upto 25
char2 = char + test
strfmt oldqwk "%s\%s.qw%c" maildir root char2
if findfirst oldqwk
strfmt renqwk "%s\%s.qw%c" maildir root char
rename oldqwk renqwk
exitfor
endif
endfor
endif
endfor
statmsg "Mail directory checked"
fetch dnldpath dldir
ltr = max + 65
for count = -1 upto 9
if count == -1
strfmt newfile "%s.QWK" board
else
strfmt newfile "%s.QW%d" board count
endif
strfmt newqwk "%s\%s" dldir newfile
if isfile newqwk
ltr++
strfmt renqwk "%s\%s.QW%c" maildir root ltr
rename newqwk renqwk
if success
statmsg "%s renamed as %s.QW%c" newfile root ltr
else
statmsg "%s not renamed." newfile
endif
else
exitfor
endif
endfor
endproc
proc done_now
if not $CARRIER
if getmail
ren_qwks()
endif
set connection statmsg off
exit
endif
endproc